<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        /**
         *  写入Cookie
         *  语法：document.cookie="键=值；expires=失效时间的GMT格式字符串"
         */ 
            function doCookie(){
                document.cookie="name=tom";
            }

    </script>
</head>
<body>
    <button onclick="doCookie()">写入Cookie</button>
    <button>获取Cookie</button>
</body>
</html>